#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 30;
int n, k;
int sum;
int as;
int a[N];
bool ioa(int as)
{
    if (as == 1)
        return false;
    for (int i = 2; i <= as / i; i++)
    {
        if (as % i == 0)
            return false;
    }
    return true;
}
void dfs(int pos, int begin)
{
    if (pos > k)
    {
        if (ioa(as))
        {
            sum++;
        }
        return;
    }
    for (int i = begin; i <= n; i++)
    {
        as += a[i];
        dfs(pos + 1, i + 1);
        as -= a[i];
    }
}
int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    dfs(1, 1);
    cout << sum;
    return 0;
}